package com.mijie.homi.service.user;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mijie.homi.common.domain.user.ThirdPartAccount;
import com.mijie.homi.common.domain.user.ThirdPartOfficialAccount;
import com.mijie.homi.dao.user.ThirdPartAccountDao;
import com.mijie.homi.listener.IntegrationHandler;

@Service
public class ThirdPartAccountService {

	@Autowired
	private ThirdPartAccountDao dao;
	@Autowired
	private IntegrationHandler integrationHandler ;
	
	public int addThirdPartAccount(ThirdPartAccount account){
		int rows =  dao.addThirdPartAccount(account);
		if(rows>0) integrationHandler.bindThridPart(account.getUserId());
		return rows;
	}
	
	public void share(ThirdPartAccount account){
		integrationHandler.shareToThirdPart(account.getUserId());
	}
	
	public ThirdPartAccount getThirdPartAccount(String accountId,int type){
		return dao.getThirdPartAccount(accountId, type);
	}
	
	public int updateThirdPartAccount(ThirdPartAccount account){
		return dao.updateThirdPartAccount(account);
	}
	
	public int followThirdPartOfficialAccount(String accountId,int type){
		return dao.followThirdPartOfficialAccount(accountId, type);
	}
	
	public List<ThirdPartAccount> listThirdPartAccountByUser(int userId){
		return dao.listThirdPartAccountByUser(userId);
	}
	
	public ThirdPartOfficialAccount getOfficialAccount(int type){
		return dao.getOfficialAccount(type);
	}
}
